package com.miaoquan.mqportal.feign;

import com.miaoquan.mqcommon.api.CommonPage;
import com.miaoquan.mqcommon.api.CommonResult;
import com.miaoquan.mqcommon.exception.ApiException;
import com.miaoquan.mqmbg.model.TbkProduct;
import com.miaoquan.mqportal.feign.hystrix.SearchFeignFactory;
import com.taobao.api.request.TbkDgMaterialOptionalRequest;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 搜索的远程服务调用
 *
 * @author Fa
 * @date 2020-04-04 23:04
 */
@FeignClient(name = "mq-api-tbk", contextId = "searchFeign", path = "/search",
        fallbackFactory = SearchFeignFactory.class)
public interface SearchFeign {

    /**
     * 淘宝客商品搜索
     */
    @GetMapping("/product")
    CommonResult<CommonPage<TbkProduct>> searchProduct(
            @RequestParam(required = false, defaultValue = "1") Long pageNum,
            @RequestParam(required = false) boolean isTmall,
            @RequestParam String q
    ) throws ApiException;

    /**
     * 通过物料搜索请求对象查询商品
     *
     * @param tbkDgMaterialOptionalRequest 物料搜索请求
     * @return 分页淘客商品数据
     */
    @PostMapping("/product/all")
    CommonResult<CommonPage<TbkProduct>> searchProduct(
            @RequestBody TbkDgMaterialOptionalRequest tbkDgMaterialOptionalRequest) throws ApiException;

}
